#ifndef __OLED_H
#define __OLED_H

#include <stdint.h>

#define OLED_SCL_PIN PA4
#define OLED_SDA_PIN PA5
#define OLED_RES_PIN PA6
#define OLED_DC_PIN PA7
#define OLED_CS1_PIN PC4
#define OLED_FS0_PIN PC5
#define OLED_CS2_PIN PE8

#define OLED_SCL_Clr() IOWrite(OLED_SCL_PIN, 0) //SCL
#define OLED_SCL_Set() IOWrite(OLED_SCL_PIN, 1)

#define OLED_SDA_Clr() IOWrite(OLED_SDA_PIN, 0) //SDA
#define OLED_SDA_Set() IOWrite(OLED_SDA_PIN, 1)

#define OLED_RES_Clr() IOWrite(OLED_RES_PIN, 0) //RES
#define OLED_RES_Set() IOWrite(OLED_RES_PIN, 1)

#define OLED_DC_Clr() IOWrite(OLED_DC_PIN, 0); //DC
#define OLED_DC_Set() IOWrite(OLED_DC_PIN, 1)

#define OLED_CS_Clr() IOWrite(OLED_CS1_PIN, 0) //CS1
#define OLED_CS_Set() IOWrite(OLED_CS1_PIN, 1)

#define OLED_ROM_CS_Clr() IOWrite(OLED_CS2_PIN, 0) //CS2
#define OLED_ROM_CS_Set() IOWrite(OLED_CS2_PIN, 1)

#define OLED_READ_FS0() IORead(OLED_FS0_PIN) //FS0

#define OLED_CMD 0
#define OLED_DATA 1

void OLED_ColorTurn(uint8_t i);
void OLED_DisplayTurn(uint8_t i);
void OLED_WR_Byte(uint8_t dat, uint8_t cmd);
void OLED_Clear(void);
void OLED_address(uint8_t x, uint8_t y);
void OLED_Display_128x64(uint8_t *dp);
void OLED_Display_16x16(uint8_t x, uint8_t y, uint8_t *dp);
void OLED_Display_8x16(uint8_t x, uint8_t y, uint8_t *dp);
void OLED_Display_5x7(uint8_t x, uint8_t y, uint8_t *dp);
void Send_Command_to_ROM(uint8_t dat);
uint8_t Get_data_from_ROM(void);
void OLED_get_data_from_ROM(uint8_t addrHigh, uint8_t addrMid, uint8_t addrLow, uint8_t *pbuff, uint8_t DataLen);
void OLED_Display_GB2312_string(uint8_t x, uint8_t y, const char *text);
void OLED_Display_string_5x7(uint8_t x, uint8_t y, uint8_t *text);
void OLED_ShowNum(uint8_t x, uint8_t y, float num, uint8_t len);
void OLED_Init(void);
#endif
